package com.mission.shaco.warehouse.models.list

import org.json.JSONArray
import org.json.JSONObject



/**
 * Created by Administrator on 2017/6/20.
 */
public class SingleList : BaseList() {
    private val serialVersionUID = 7981560250804001000L

    fun takeWrongItem(error:String,position:Int) {
        var js = jsonArray.get(position) as JSONObject

        var qty = js.getInt("qty")

        var overQty = 0;
        if(js.has("qty_bak")){
            overQty = js.getInt("qty_bak")
            js.put("qty",qty-overQty)
            this.completeArray.put(js)
            val wrongjs = JSONObject(js.toString())

            wrongjs.put("errorCode",error)
            wrongjs.put("qty",overQty)
            this.wrongItemArray.put(wrongjs)
        }else{
            js.put("errorCode",error)
            this.wrongItemArray.put(js)
        }

        removePosition(position)
    }

    fun overdueCheck():Boolean{
        var length = jsonArray.length().equals(0)
        if(length ){
            return true;
        }
        var nowTime = System.currentTimeMillis()/1000
        if( nowTime - lifeTime > 24 * 60 * 60){
            return true;
        }else{
            return false;
        }

    }

}

